package thirtysix

import org.apache.spark.{SparkConf, SparkContext}

/**
  * @author gouyangyang on 2019/3/11/011 13:32
  */
object SparkMap {
  /**
    * map() 就是将函数用于RDD的每个元素，将返回值构成新的RDD
    * flatMap() 是将函数应用于RDD的每一个元素,将返回迭代器的所有内容构成新的RDD
    */
  def main(args: Array[String]): Unit = {
    val conf = new SparkConf().setAppName("SparkMap").setMaster("local")
    val sc = new SparkContext(conf)
    val rdd = sc.parallelize(List("coffee panda", "happy panda", "happiest panda party"))
    rdd.flatMap(x => x.split("")).collect();
    rdd.count();
    sc.stop();
  }
}
